package framework.agent;

import org.apache.log4j.Logger;

import common.LogCategory;

import framework.Agent;
import framework.Message;

public class AbstractAgent implements Agent {

	protected static final Logger log = LogCategory.getCategory(AbstractAgent.class);
	private final String agentName;

	protected AbstractAgent(String agentName) {
		this.agentName = agentName;
	}

	@Override
	public String getAgentName() {
		return agentName;
	}

	//@Override
	protected <M extends Message> M sendAndWait(Message message, String serviceName) {
		return sendAndWait(message, serviceName, defaultWaitTime());
	}

	//@Override
	protected <M extends Message> M sendAndWait(Message message, String serviceName, long waitPeriodInMilliseconds) {
		M result = null;
//		try { // TODO
			result = Mailer.sendAndWait(message, serviceName, agentName, waitPeriodInMilliseconds);
//		}
//		if (result.getProblem() != null) {
//		} else {
			return result;
//		}
	}

	protected long defaultWaitTime() {
		return 135000L;
	}
}
